namespace Fftw
{
    using System;
    using System.Runtime.InteropServices;
    
    public class PlanComplex1D : Plan
    {
        [DllImport ("libfftw3")]
        private static extern IntPtr fftw_plan_dft_1d(int n, Complex[] in_data, Complex[] out_data, Direction direction, uint flags);
        
        [DllImport ("libfftw3")]
        private static extern void fftw_destroy_plan(IntPtr plan);
        
        public PlanComplex1D(Complex[] in_data, Direction direction, uint flags)
        {
            this.in_data = in_data;
            out_data = new Complex[in_data.Length];
            this.flags = flags;
            this.direction = direction;
            this.raw = IntPtr.Zero;
            
            CreatePlan();
        }
        
        ~PlanComplex1D()
        {
            fftw_destroy_plan(raw);
        }
        
        protected override void CreatePlan()
        {
            raw = fftw_plan_dft_1d(in_data.Length, in_data, out_data, direction, flags);
        }
    }
}
        
